/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * framePrincipal.java
 *
 * Created on 27/06/2009, 21:58:17
 */
package aprendizadosemfio.Telas;

import aprendizadosemfio.configuracoes.Configurar;
import aprendizadosemfio.entidades.TipoDeRede;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Toolkit;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Igor
 */
public class FramePrincipal extends javax.swing.JFrame {

    ArrayList<TipoDeRede> todasRedes = new Configurar().configurarRedes();
    FrameQuiz fQuiz = new FrameQuiz();
    /** Creates new form framePrincipal */
    public FramePrincipal() {
        super("APRENDIZADO DE REDES SEM FIO");
        initComponents();
        barra1.setAlignmentY(CENTER_ALIGNMENT);
        barra2.setAlignmentY(CENTER_ALIGNMENT);

        double width = Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2;
        double height = Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2;
        double widthf = getWidth() / 2;
        double heigthf = getHeight() / 2;
        int widthFinal = (int) (width - widthf);
        int heigthFinal = (int) (height - heigthf);
        setLocation(widthFinal, heigthFinal);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        barra1 = new javax.swing.JToolBar();
        WPAN = new javax.swing.JButton();
        WMAN = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        barra2 = new javax.swing.JToolBar();
        jButton2 = new javax.swing.JButton();
        Celulares = new javax.swing.JButton();
        jButtonQuiz = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        Sair = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        CelularMenu = new javax.swing.JMenuItem();
        GerenciaeMobi = new javax.swing.JMenuItem();
        OutrasRedes = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        barra1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 3));
        barra1.setFloatable(false);
        barra1.setOrientation(1);
        barra1.setRollover(true);

        WPAN.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/bluetooth.png"))); // NOI18N
        WPAN.setText("WPAN");
        WPAN.setBorderPainted(false);
        WPAN.setFocusable(false);
        WPAN.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        WPAN.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        WPAN.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                WPANActionPerformed(evt);
            }
        });
        barra1.add(WPAN);

        WMAN.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/wimax.PNG"))); // NOI18N
        WMAN.setText("WMAN");
        WMAN.setBorderPainted(false);
        WMAN.setFocusable(false);
        WMAN.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        WMAN.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        WMAN.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                WMANActionPerformed(evt);
            }
        });
        barra1.add(WMAN);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/Wlan2.gif"))); // NOI18N
        jButton1.setText("WLAN");
        jButton1.setBorderPainted(false);
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        barra1.add(jButton1);

        barra2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 3, true));
        barra2.setFloatable(false);
        barra2.setOrientation(1);
        barra2.setRollover(true);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/3g.PNG"))); // NOI18N
        jButton2.setText("WWAN");
        jButton2.setBorderPainted(false);
        jButton2.setFocusable(false);
        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        barra2.add(jButton2);

        Celulares.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/nexus-one-128x128.png"))); // NOI18N
        Celulares.setText("CELULARES");
        Celulares.setBorderPainted(false);
        Celulares.setFocusable(false);
        Celulares.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Celulares.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Celulares.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CelularesActionPerformed(evt);
            }
        });
        barra2.add(Celulares);

        jButtonQuiz.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/quiz-icon3.png"))); // NOI18N
        jButtonQuiz.setText("QUIZ");
        jButtonQuiz.setBorderPainted(false);
        jButtonQuiz.setFocusable(false);
        jButtonQuiz.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonQuiz.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButtonQuiz.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonQuizActionPerformed(evt);
            }
        });
        barra2.add(jButtonQuiz);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel1.setText("Redes pessoais de baixo alcance voltadas à comunicação de");

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel2.setText("pequenos aparelhos. Ex.: Bluetooth, ZigBee e HomeRF");

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel3.setText("Redes metropolitanas com grande alcance e abrangência.");

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel4.setText("Bastante utilizada por operadoras de telecomunicação");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel5.setText("Teste seu aprendizado no jogo de perguntas e respostas sobre redes sem fio");

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel6.setText("Redes  locais  de baixo alcance , utilizadas  para  comunicar");

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel7.setText("componentes próximos em redes privadas ou à internet");

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel8.setText("Redes conhecidas como redes vastas sem fios. Promovem a comunicação entre");

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel9.setText("telefones móveis, sendo também chamadas de redes celular-móveis");

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel10.setText("Redes de telefonia móvel destinadas à comunicação entre estações base para prover");

        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel11.setText("funcionamento de telefonia celular");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(barra1, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel4)
                    .addComponent(jLabel7)
                    .addComponent(jLabel6)
                    .addComponent(jLabel3)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 338, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(barra2, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel9)
                    .addComponent(jLabel11)
                    .addComponent(jLabel8)
                    .addComponent(jLabel10))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(barra1, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(59, 59, 59)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addGap(121, 121, 121)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel4)
                .addGap(99, 99, 99)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel7)
                .addContainerGap(81, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(60, 60, 60)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel9)
                .addGap(121, 121, 121)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
                .addComponent(jLabel5)
                .addGap(104, 104, 104))
            .addComponent(barra2, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
        );

        jMenu1.setText("Arquivo");

        Sair.setText("Sair");
        Sair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SairActionPerformed(evt);
            }
        });
        jMenu1.add(Sair);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Apresentações");

        CelularMenu.setText("Celular");
        CelularMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CelularMenuActionPerformed(evt);
            }
        });
        jMenu2.add(CelularMenu);

        GerenciaeMobi.setText("Gerência e mobilidade");
        jMenu2.add(GerenciaeMobi);

        OutrasRedes.setText("Outras redes sem fio");
        jMenu2.add(OutrasRedes);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void SairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SairActionPerformed
        System.exit(1);
    }//GEN-LAST:event_SairActionPerformed

    private void WPANActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WPANActionPerformed
        FrameGuia frameGuia = new FrameGuia();
        frameGuia.setVisible(true);
        frameGuia.setTipoDeRede(todasRedes.get(0));
        this.dispose();
    }//GEN-LAST:event_WPANActionPerformed
    public int fechar(){
        this.dispose();
        new FramePrincipal().setVisible(true);
        return 1;
    }

    private void WMANActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WMANActionPerformed
        // TODO add your handling code here:
        FrameGuia frameGuia = new FrameGuia();
        frameGuia.setTipoDeRede(todasRedes.get(3));
        frameGuia.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_WMANActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        FrameGuia frameGuia = new FrameGuia();
        frameGuia.setTipoDeRede(todasRedes.get(1));
        frameGuia.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
       FrameGuia frameGuia = new FrameGuia();
       frameGuia.setTipoDeRede(todasRedes.get(2));
        frameGuia.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void CelularesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CelularesActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_CelularesActionPerformed

    private void jButtonQuizActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonQuizActionPerformed
        // TODO add your handling code here:
        
        fQuiz.setVisible(true);
       // dispose();
        //this.dispose();
    }//GEN-LAST:event_jButtonQuizActionPerformed

    private void CelularMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CelularMenuActionPerformed
        try
        {
            Desktop.getDesktop().open(new File("aprendizadosemfio/arquivos/"));
        }
        catch (IOException ex)
        {
            Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_CelularMenuActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FramePrincipal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem CelularMenu;
    private javax.swing.JButton Celulares;
    private javax.swing.JMenuItem GerenciaeMobi;
    private javax.swing.JMenuItem OutrasRedes;
    private javax.swing.JMenuItem Sair;
    private javax.swing.JButton WMAN;
    private javax.swing.JButton WPAN;
    private javax.swing.JToolBar barra1;
    private javax.swing.JToolBar barra2;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButtonQuiz;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables

    public void setarFullScreen() {
        Insets in = Toolkit.getDefaultToolkit().getScreenInsets(this.getGraphicsConfiguration()); //recupera aspectos gráficos do ambiente

        Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); //recupera dimensão do ambiente

        int width = d.width - (in.left + in.top);
        int height = d.height - (in.top + in.bottom);
        setSize(width, height); //calcula dimensões de tela cheia e atribui ao programa
        setLocation(in.left, in.top); //posiciona frame em tela cheia para evitar que haja perda das laterais
        
    }
}
